package com.songcha.sakura.ui.activity

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import com.songcha.library_base.base.BaseActivity
import com.songcha.sakura.databinding.ActivitySplashBinding
import com.songcha.sakura.ui.activity.test.TestActivity
import com.songcha.sakura.util.MyJumpUtil
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import java.util.concurrent.TimeUnit


class SplashActivity : BaseActivity(){
    //private var isDebug=true
    private var isDebug=false
    private var binding:ActivitySplashBinding?=null

    override fun getRootView(): View? {
        binding=ActivitySplashBinding.inflate(layoutInflater)
        return binding!!.root
    }

    @SuppressLint("CheckResult")
    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        if(!isDebug){
            Observable.timer(2000,TimeUnit.MILLISECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe{
                    finish()
                    //关闭返回动画
                    overridePendingTransition(0,0)
                    //JumpUtil.toMain(this)
                }
        }else{
            MyJumpUtil.toActivity(this, TestActivity::class.java)
        }
    }

    override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true
        }
        return super.onKeyUp(keyCode, event)
    }

    override fun isImmerseStatusBar(): Boolean {
        return true
    }


}

